<template>
	<div class="app">
		<h1>我是App组件</h1>
		<h4>儿子给我的玩具是：{{wanju}}</h4>
		<!-- <Son @get-toy="saveToy"></Son> -->
		<Son ref="haizi"></Son>
	</div>
</template>

<script>
	import Son from '../components/Son.vue'

	export default {
		name:'App',
		components:{Son},
		data() {
			return {
				wanju:''
			}
		},
		/* methods: {
			saveToy(value){
				console.log(this)
				this.wanju = value
			}
		}, */
		mounted() {
			this.$refs.haizi.$on('get-toy',(value)=>{
				console.log(this)
				this.wanju = value
			})
		},
	}
</script>

<style>
	.app{
		background-color: gray;
		padding: 20px;
	}
</style>